//
//  SettingSubMenu.m
//  bank_ipad2
//
//  Created by nxj bill on 12-3-12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "SettingSubMenu.h"

#import "DetailViewController.h"
#import "BankAllMenu.h"
#import "Constants.h"

@implementation SettingSubMenu

@synthesize dataDict,dataSourceArray,detailViewController;
#pragma mark -
#pragma mark View lifecycle
- (void)action:(id)sender
{
	BankAllMenu *object = [[BankAllMenu alloc] initWithNibName:@"BankAllMenu" bundle:nil];
	object.detailViewController = self.detailViewController;
	[[self navigationController] pushViewController:object animated:YES];
	[object release];
	
}
- (void)viewDidLoad {
	[super viewDidLoad];
	self.title=@"用户设置";
	//	self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"food.jpg"]];
	
	UIImageView * image1 = [[UIImageView alloc] initWithFrame: CGRectMake(0, 0, 0, 0)];
	image1.image= [UIImage imageNamed:kBackground];
	[image1 setBackgroundColor:[UIColor clearColor]];	
	self.tableView.backgroundView = image1;
	[image1 release];
	
//    self.clearsSelectionOnViewWillAppear = NO;
//    self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
	self.dataSourceArray = [NSMutableArray array];
	//1
	//label
	UILabel * label = [[UILabel alloc] initWithFrame: CGRectMake( 160.0,50.0,100.0,30.0)];
	[label setBackgroundColor:[UIColor clearColor]];	
	label.text = @"账户查询";
	
	//image
	UIImageView * image = [[UIImageView alloc] initWithFrame: CGRectMake(20, 2, 110, 110)];
	image.image= [UIImage imageNamed:@"icon_accquery.png"];
	[image setBackgroundColor:[UIColor clearColor]];
	[self.dataSourceArray addObject:[NSArray arrayWithObjects:label,image,nil]];

	[label release];
	[image release];

	
	//2
	label = [[UILabel alloc] initWithFrame: CGRectMake( 160.0,50.0,100.0,30.0)];
	[label setBackgroundColor:[UIColor clearColor]];
	label.text = @"账户管理";
	
	image = [[UIImageView alloc] initWithFrame: CGRectMake(20, 2, 110, 110)];
	image.image= [UIImage imageNamed:@"icon_setting.png"];
	
	[self.dataSourceArray addObject:[NSArray arrayWithObjects:label,image,nil]];
	[label release];
	[image release];	
	
	
	UIBarButtonItem *temporaryBarButtonItem1 = [[UIBarButtonItem alloc] initWithTitle:@"显示全部菜单"
																				style:UIBarButtonItemStylePlain	// note you can use "UIBarButtonItemStyleDone" to make it blue
																			   target:self
																			   action:@selector(action:)];
	
	self.navigationItem.rightBarButtonItem = temporaryBarButtonItem1;
	
	[temporaryBarButtonItem1 release];	
	
}

- (void)viewWillAppear:(BOOL)animated {
	[super viewWillAppear:animated];
	
	NSString *filePathOfIndex = [[NSBundle mainBundle] pathForResource:@"settingsubmenu.html" ofType:nil];
	NSString *strAbsPath= [NSString stringWithFormat:@"encodeURI('file:///%@')",filePathOfIndex];
	NSString *url  = [detailViewController.detailDescriptionWeb stringByEvaluatingJavaScriptFromString:strAbsPath];
	[detailViewController.detailDescriptionWeb stopLoading];
	[detailViewController.detailDescriptionWeb loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
	
	
}
/*
 - (void)viewDidAppear:(BOOL)animated {
 [super viewDidAppear:animated];
 }
 */
/*
 - (void)viewWillDisappear:(BOOL)animated {
 [super viewWillDisappear:animated];
 }
 */
/*
 - (void)viewDidDisappear:(BOOL)animated {
 [super viewDidDisappear:animated];
 }
 */

// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	return interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
	
    interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}


#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView {
    // Return the number of sections.
    return 1;
}


- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
	int length = [self.dataSourceArray  count];
    return length;
}

//系统
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
	
	return ([indexPath row] == 0) ? 110.0 : 110.0;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"CellIdentifier";
    
    // Dequeue or create a cell of the appropriate type.
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    
	
	UILabel *label;
	label = [[self.dataSourceArray objectAtIndex: indexPath.row] objectAtIndex:0];
	[cell.contentView addSubview:label];
	
	UIImageView *image;
	image = [[self.dataSourceArray objectAtIndex: indexPath.row] objectAtIndex:1];
	[cell.contentView addSubview:image];
	
	
    // Configure the cell.
    //cell.textLabel.text = [NSString stringWithFormat:@"Row %d", indexPath.row];
    return cell;
}


/*
 // Override to support conditional editing of the table view.
 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
 // Return NO if you do not want the specified item to be editable.
 return YES;
 }
 */


/*
 // Override to support editing the table view.
 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
 
 if (editingStyle == UITableViewCellEditingStyleDelete) {
 // Delete the row from the data source
 [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
 }   
 else if (editingStyle == UITableViewCellEditingStyleInsert) {
 // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
 }   
 }
 */


/*
 // Override to support rearranging the table view.
 - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
 }
 */


/*
 // Override to support conditional rearranging of the table view.
 - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
 // Return NO if you do not want the item to be re-orderable.
 return YES;
 }
 */


#pragma mark -
#pragma mark Table view delegate

- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    /*
     When a row is selected, set the detail view controller's detail item to the item associated with the selected row.
     */
    //detailViewController.detailItem = [NSString stringWithFormat:@"Row %d", indexPath.row];
	
	
	//Query *q = [[Query alloc] initWithNibName:@"Query" bundle:nil];
	
	
	
	//TabDefaultController *uiCtrl = [super createTabController:kTabBankLoginControllerTag];
	//ui需要nav控制
	//UIViewController *uiCtrl = [[Login alloc] initWithNibName:@"LoginNew" bundle:nil];
	//UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:self] autorelease];
	//[[self navigationController] pushViewController:q animated:YES];
	
	
	
	//[[self navigationController] pushViewController:accAppendViewController animated:YES];
}


#pragma mark -
#pragma mark Memory management

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Relinquish ownership any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
	
	dataDict= nil;
	dataSourceArray= nil;
}


- (void)dealloc {
	[dataDict release];
	[dataSourceArray release];
    [super dealloc];
}


@end

@end

